package main

import (
	"fmt"
)

// Shape 定义一个图形接口
type Shape interface {
	Draw()
}

// Circle 圆形
type Circle struct{}

func (c *Circle) Draw() {
	fmt.Println("Drawing a Circle")
}

// Rectangle 矩形
type Rectangle struct{}

func (r *Rectangle) Draw() {
	fmt.Println("Drawing a Rectangle")
}

// Triangle 三角形
type Triangle struct{}

func (t *Triangle) Draw() {
	fmt.Println("Drawing a Triangle")
}

// Drawer 绘图器
type Drawer struct {
	shape Shape
}

func (d *Drawer) Draw() {
	d.shape.Draw()
}

func main() {
	drawer := Drawer{shape: &Circle{}}
	drawer.Draw() // 输出：Drawing a Circle

	drawer.shape = &Rectangle{}
	drawer.Draw() // 输出：Drawing a Rectangle

	drawer.shape = &Triangle{} // 添加三角形
	drawer.Draw()              // 输出：Drawing a Triangle
}
